package java基础知识.java泛型;

import java.util.ArrayList;
import java.util.List;

/**
 * @author coderFu
 * @create 2022/3/11
 * java的泛型
 * 参数化类型，在传递参数的时候将具体的类型进行参数化
 * 通过具体的形参来获取参数的真实情况
 */
public class CoderGeneral {

    public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        List<String> list = new ArrayList<>();
        list.add("a");
        test(list);
        
        CoderDemoGeneric<String> demoGeneric = new CoderDemoGeneric<>("123456");

        String key = demoGeneric.getKey();
        System.out.println(key);

        CoderDemoGeneric<Integer> demoGeneric2 = new CoderDemoGeneric<>(123456);
        System.out.println(demoGeneric2.getKey());

        CoderDemoGeneric<Number> demoGeneric3 = new CoderDemoGeneric<>(123456);
        System.out.println("检测泛型的父子类兼容型：通过通配符？");
        demoGeneric2.ShowKeyValue(demoGeneric3);

        demoGeneric3.ShowKeyValue(demoGeneric2);

        CoderGenericMethod coderGenericMethod = new CoderGenericMethod();

        Object test = coderGenericMethod.test(Object.class);

        coderGenericMethod.test(Class.forName("java基础知识.java泛型.CoderDemo"));

        // 泛型类与边长参数
        coderGenericMethod.test("12346576",":dads32");

        // 通过泛型方法来创建Object 实例对象
        System.out.println(test);


    }

    public static   void  test(List<String> datas){
        System.out.println(datas);
    }


}
